package com.csust.homework.exer01;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class Homework01 {
    public static void main(String[] args) throws Exception {
        Class<?> clazz = Class.forName("com.csust.homework.exer01.PrivateTest");
        Object object = clazz.newInstance();
        Field declaredField = clazz.getDeclaredField("name");
        declaredField.setAccessible(true);
        declaredField.set(object,"hellojava");
        Method method = clazz.getMethod("getName");
        System.out.println(method.invoke(object));


    }
}

class  PrivateTest{
    private String name = "hellokitty";

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
